<template>
	<view>
		<!-- <view class="search-bar-area">
		<uni-search-bar bgColor="#f6f6f6" :radius="100" @confirm="search">
		</uni-search-bar>
	</view> -->
		<view class="content">
			<sl-filter :independence="true" :color="titleColor" :themeColor="themeColor" :menuList.sync="menuList"
				@result="result"></sl-filter>
		</view>
		<view style="" @tap="toDetail" v-for="(item, idx) in actList" :key="idx" :data-recruit-id="item.id">
			<view class="service-box" >
				<view class="serbox_topleft">{{item.orgName}}</view>
				<!-- <view class="serbox_topright"><view style="position: absolute;right: 38rpx;top: 5rpx;">1</view><view style="position: absolute;right: 15rpx;top: 15rpx;font-size: 14rpx;">/2</view></view> -->
				<view class="serbox_center">{{item.title}}</view>
				<view class="serbox_bottomleft">
					<image src="/static/images/icon_rec_location.png"></image>
					{{item.sysOrgName}}
				</view>
				<view class="serbox_bottomright">{{item.createTime}}</view>
			</view>
		</view>
		<view class="no_data" v-if="actList.length===0">暂无数据~</view>
		<view class="no_more" v-if="actList.length!==0&&noMore">没有更多数据了~</view>
	</view>
</template>

<script>
	import slFilter from '@/components/sl-filter/sl-filter.vue';
	var t = require("../../utils/request.js"),
		config = require("../../utils/config.js").config,
		a = function(t) {
			return t && t.__esModule ? t : {
				default: t
			};
		}(require("../../utils/api.js")),
		e = require("../../utils/util.js"),
		i = a.default.recruitList,
		o = a.default.dictionaryCounty,
		app = getApp();
	import {
		serviceList,
		getdict,
		gettypelist,
		getadress
	} from '../../api/service.js'
	export default {
		data() {
			return {
				themeColor: '#000000',
				titleColor: '#666666',
				filterResult: '',
				menuList: [{
						'title': '服务类型',
						'key': 'serviceGroup',
						'isSort': true,
						'reflexTitle': true,
						'detailList': [{
								'title': '服务类型',
								'value': ''
							},
							{
								'title': '1',
								'value': 'add_time'
							},
							{
								'title': '2',
								'value': 'wages_up'
							},
							{
								'title': '3',
								'value': 'location'
							}
						]
					},
					{
						'title': '服务时间',
						'key': 'serviceTime',
						'isSort': true,
						'reflexTitle': true,
						'detailList': [{
								'title': '服务时间',
								'value': ''
							},
							{
								'title': '今天',
								'value': 'add_time'
							},
							{
								'title': '近三天',
								'value': 'wages_up'
							},
							{
								'title': '近一月',
								'value': 'location'
							}
						]
					}
				],
				startTime: '',
				endTime: '',
				nowId: '',
				remark: '',
				datetimerange: '',
				need: '',
				level: 2,
				provinceId: "",
				cityId: "",
				page: 1,
				pageSize: 4,
				county: "全部",
				countyId: "",
				countyIdx: 0,
				category: "全部活动",
				categoryId: "",
				categoryIdx: 0,
				order: "智能筛选",
				orderIdx: 0,
				orderId: "",
				countyList: [{
					name: "全部",
					id: "",
					_id: "",
					code: ""
				}],
				categoryList: [{
					name: "全部活动",
					value: "",
					_id: ""
				}],
				orderList: [{
					name: "智能筛选",
					value: "",
					_id: ""
				}],
				actList: [{
					name: '1',
					id: 1
				}],
				noMore: !1,
				serviceGroup:'',
				serviceTime:''
			};
		},

		components: {
			slFilter
		},
		props: {},
		onLoad: function(t) {
			var a = this;

			try {
				var i = uni.getStorageSync("areaId");
				console.log(i), this.setData({
					provinceId: i.p_id,
					cityId: i.c_id,
					countyId: i.d_id,
					level: i.level
				});
			} catch (t) {
				console.log(t);
			}

			this.getServiceData()
			this.getdict()
			// this.getadress()
			this.gettypelist()
		},
		onReady: function() {},
		onShow: function() {},
		onHide: function() {},
		onUnload: function() {},
		onPullDownRefresh: function() {
			var t = this;
			this.setData({
				page: 1,
				noMore: !1
			})
			this.getServiceData()
		},
		onReachBottom: function() {
			var t = this;

			if (!this.noMore) {
				var a = this.page;
				this.setData({
					page: ++a
				})
				this.getServiceData()
			}
		},
		onShareAppMessage: function() {
			return {
				title: "让公益更生活 让生活更公益",
				path: "/pages/index/index",
				imageUrl: "/static/images/zyh_logo.jpg"
			};
		},
		watch: {
			datetimerange(newval) {
				console.log('范围选:', this.datetimerange);
			}
		},
		methods: {

			getadress() {
				getadress().then((ret) => {
					console.log(ret)
					if (ret.success) {
						this.menuList[0].detailList = ret.data
						console.log(this.menuList[0].detailList)
					}
				})
			},
			gettypelist() {
				gettypelist().then((ret) => {
					console.log(ret)
					if (ret.success) {
						this.menuList[0].detailList = ret.data
						this.menuList[0].detailList.forEach(element =>
							element.title = element.value);
						this.menuList[0].detailList.forEach(element =>
							element.value = element.code);
							let data={
									'title': '全部',
									'value': ''
								}
								this.menuList[0].detailList.unshift(data)
					}
				})
			},
			result(val) {
				// let datas=JSON.stringify(val)	
						let key='serviceGroup'
						let keys='serviceTime'
					if(val[key]==''){
						this.serviceGroup==''
					}else if(val[key]!==''&&val[key]!==null&&val[key]!==undefined){
						this.serviceGroup=val[key]
					}
					if(val[keys]==''){
						this.serviceTime==''
					}else if(val[keys]!==''&&val[keys]!==null&&val[keys]!==undefined){
						this.serviceTime=val[keys]
					}
					this.setData({
						page:1
					})
					this.getServiceData()
				// if(data.serviceGroup)
				
			},
			getdict() {
				getdict().then((ret) => {
					console.log(ret)
					if (ret.success) {

						this.menuList[1].detailList = ret.data
						this.menuList[1].detailList.forEach(element =>
							element.title = element.value);
						this.menuList[1].detailList.forEach(element =>
							element.value = element.code);
							let data={
									'title': '全部',
									'value': ''
								}
								this.menuList[1].detailList.unshift(data)
					}
				})
			},
			getServiceData() {
				var that = this
				var uid = app.globalData.zyzId
				if (!uid) {
					uni.navigateTo({
						url: "/pages/entry/login"
					})
				}
				serviceList({
					"pageSize": this.pageSize,
					"pageNo": this.page,
					'serviceGroup':this.serviceGroup,
					'serviceTime':this.serviceTime
				}).then((ret) => {
					console.log(ret)
					if (ret.success) {
						ret.data.length < 10 && that.setData({
							noMore: !0
						});
						var i = [];
						ret.data.rows.forEach(function(t) {
							t.createTime = t.createTime.substring(0, 10);
							// t.thumb = t.imageUrl ? config.host + "/sysFileInfo/preview?id=" + t.imageUrl : "/static/images/defaultorg.png";
							i.push(t);
						}), that.setData({
							actList: i
						});
						console.log(this.actList)
					}
				})
			},
			toDetail: function(t) {
				uni.navigateTo({
					url: "/pages/service/detail?id=" + t.currentTarget.dataset.recruitId
				});
			}
		}
	};
</script>
<style>
	@import '@/common/uni.css';

	.title {
		padding: 5px 13px;
	}

	page {
		width: 100%;
		height: auto;
		/* min-height: 100%; */
		background: #f4f4f4;
		/* padding-top: 100rpx; */
		padding-bottom: 60rpx;
	}

	.service-box {
		position: relative;
		margin: 10rpx;
		width: 97%;
		height: 250rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		box-shadow: 0rpx 0rpx 10rpx #d5d5d5;
	}

	.serbox_topleft {
		position: absolute;
		left: 30rpx;
		top: 30rpx;
		color: #f97373;
		padding: 5rpx 5rpx;
		background-color: #ffeeee;
		border-radius: 10rpx;
	}

	.serbox_topright {
		position: absolute;
		right: 30rpx;
		top: 30rpx;
		padding: 5rpx 5rpx;
		border-radius: 10rpx;
	}

	.serbox_center {
		position: absolute;
		left: 30rpx;
		top: 110rpx;
		font-size: 36rpx;
	}

	.serbox_bottomleft {
		font-size: 18rpx;
		position: absolute;
		left: 30rpx;
		bottom: 30rpx;
		color: #333333;
	}

	.serbox_bottomleft image {
		width: 24rpx;
		height: 24rpx;
	}

	.serbox_bottomright {
		position: absolute;
		right: 30rpx;
		bottom: 30rpx;
		font-size: 18rpx;
		color: #333333;
	}

	.select_wrapper {
		position: fixed;
		top: 0;
		/*  #ifdef  H5  */
		top: 88rpx;
		/*  #endif  */
		left: 0;
		z-index: 99;
		width: 100%;
		height: 100rpx;
		justify-content: flex-start;
		background: #fff;
		border-top: 1rpx solid #e1e2e3;
		background: #f4f4f4;
		margin-bottom: 20rpx;
		padding-bottom: 10rpx;
	}

	.select_wrapper picker {
		flex: 0 0 33.33%;
		width: 33.33%;
		height: 90rpx;
	}

	.select_wrapper picker.double {
		flex: 0 0 50%;
		width: 50%;
		height: 90rpx;
	}

	.select_wrapper .select_sec {
		width: 100%;
		height: 90rpx;
		background: #fff;
	}

	.select_wrapper picker+picker>.select_sec {
		border-left: 1rpx solid #e1e2e3;
	}

	.select_sec .txt {
		flex: none;
		height: 100%;
		line-height: 90rpx;
	}

	.select_sec image {
		flex: 0 0 12rpx;
		width: 12rpx;
		height: 6rpx;
		margin-left: 12rpx;
	}

	.act_sec {
		width: 100%;
		min-height: 445rpx;
		height: auto;
		padding: 30rpx;
		margin-bottom: 10rpx;
		background: #fff;
	}

	.img_sec {
		position: relative;
		width: 100%;
		height: 280rpx;
		margin-bottom: 30rpx;
	}

	.img_sec .tag {
		position: absolute;
		top: -8rpx;
		left: -8rpx;
		z-index: 3;
		width: 160rpx;
		height: 52rpx;
	}

	.img_sec .tag image {
		z-index: 4;
	}

	.img_sec .tag image,
	.img_sec .tag text {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
	}

	.img_sec .tag text {
		z-index: 5;
		text-align: center;
		line-height: 48rpx;
		font-size: 24rpx;
		color: #fff;
	}

	.img_sec .thumb {
		width: 100%;
		height: 100%;
		border: 1rpx solid #e1e2e3;
		border-radius: 10rpx;
	}

	.img_sec .headimg {
		position: absolute;
		bottom: -40rpx;
		right: 30rpx;
		z-index: 5;
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
	}

	.act_sec .title {
		width: 100%;
		margin-bottom: 20rpx;
		font-size: 32rpx;
		color: #333;
	}

	.act_sec .desc,
	.act_sec .title {
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
	}

	.act_sec .desc {
		font-size: 24rpx;
	}
</style>
